home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 11 - 1995 / 11.02 Feb 95 / Yenta / Erics C++ Libraries / Interface Classes / CPPRadioButton.cp < prev    next >
Encoding:
Text File  |  1996-04-04  |  2.5 KB  |  93 lines  |  [TEXT/KAHL]

  1. /********************************************************* DEFINITION
  2.     DATE:    9/27/93
  3.     AUTHOR: Eric R. Rosé
  4.     
  5.     CLASS:  CPPRadioButton
  6.     
  7.     SUPERCLASS: CPPVisualObject
  8.     
  9.         This C++ class manages a radio button control
  10.     
  11. ********************************************************************/
  12.  
  13. #include <CPPRadioButton.h>
  14. #include <CPPRadioCluster.h>
  15.  
  16. extern    Rect    kDefaultRect;
  17. extern    Rect    kEmptyRect;
  18.  
  19. /*-----------------------------------------------------------------*/
  20. /*------------------------ PUBLIC METHODS -------------------------*/
  21. /*-----------------------------------------------------------------*/
  22.  
  23.     CPPRadioButton::CPPRadioButton (CPPWindow *itsWindow, 
  24.                                     CPPRadioCluster *itsCluster,
  25.                                     short ResID,
  26.                                     Boolean initiallyOn,
  27.                                     Boolean canBeTarget,
  28.                                     Boolean active, Boolean visible) :
  29.                 CPPControl (itsWindow, ResID, FALSE, canBeTarget, 
  30.                                  active, visible)
  31.     /* load a control resource and initialize with the given data */
  32.     {
  33.         if ((this->myCluster = itsCluster) != NULL)
  34.           this->myCluster->AppendItem (this);
  35.         
  36.         if (this->theControl)
  37.           SetValue (initiallyOn);
  38.     }
  39.  
  40. /*-----------------------------------------------------------------*/
  41.  
  42.     CPPRadioButton::CPPRadioButton (CPPWindow *itsWindow, 
  43.                                     CPPRadioCluster *itsCluster,
  44.                                     Rect *itsBounds,
  45.                                     StringPtr itsText, Boolean initiallyOn,
  46.                                      Boolean useWindowFont,
  47.                                     Boolean canBeTarget,
  48.                                     Boolean active, Boolean visible) :
  49.                 CPPControl (itsWindow, itsBounds, radioButProc,
  50.                             itsText, FALSE, useWindowFont,
  51.                             canBeTarget, active, visible)
  52.     {
  53.         if ((this->myCluster = itsCluster) != NULL)
  54.           this->myCluster->AppendItem (this);
  55.           
  56.         // if the radio button is 'on', call our method to
  57.         // insure exclusivity within a group of radio buttons
  58.         if (this->theControl && initiallyOn)
  59.           DoOnClick ();
  60.     }
  61.  
  62. /*-----------------------------------------------------------------*/
  63.  
  64.     CPPRadioButton::~CPPRadioButton (void)
  65.     {
  66.         
  67.     }
  68.  
  69. /*-----------------------------------------------------------------*/
  70.  
  71.     char    *CPPRadioButton::ClassName (void)
  72.     {
  73.         return "CPPRadioButton";
  74.     }
  75.  
  76. /*-----------------------------------------------------------------*/
  77.  
  78.     void    CPPRadioButton::DoOnClick (void)
  79.     /* when a radio button is clicked, turn it on */
  80.     /* SUBCLASS SHOULD OVERRIDE */
  81.     {
  82.         // if it is part of a cluster, have the cluster
  83.         // set its value (so it can insure exclusivity)
  84.         if (this->myCluster)
  85.           this->myCluster->TurnOn(this);
  86.         else
  87.           SetValue (1);
  88.         
  89.         // let the superclass run the callback proc
  90.         CPPControl::DoOnClick();
  91.     }
  92.  
  93.